home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
015a
/
fdate25a.zip
/
FDATE.DOC
next >
Wrap
Text File
|
1991-11-14
|
31KB
|
852 lines
FDATE Version 2.5a Nov 13, 1991
===================================================================
FDATE: a utility for date manipulation in batch files.
===================================================================
Stephen Ferg 5113 N. 8th Road, Arlington, VA 22205-1201
Voice (703) 525-22541 CompuServe 73377,1157
===================================================================
Format: FDATE /Ffunc /Nnum /Adate /Bdate /Iformat /Oformat /Pstring
===================================================================
FDATE PARAMTERS
===============
The parameters that are required depend on the function requested.
Parameters that are specified, but not needed, are ignored.
Executing FDATE without any parameters displays a brief help screen.
Parameters can be in any order and upper or lower case.
Note that although format specifications are not case sensitive,
they ARE "text sensitive". If any characters are missing,
added, or mistyped, the format specification will be rejected.
(A common mistake is to enter "/format" instead of "/Fformat".)
/F requests a particular FDATE function
If this parameter is not specified, or is specified incorrectly,
FDATE displays a help screen. If you unexpectedly get the help
screen displayed, you probably have omitted the /F parameter.
/N number of days (always a number)
/A date A (for math functions, a number)
/B date B (for math functions, a number)
/I specifies format of input date(s)
/O specifies format of output date
/L specifies language of output. If omitted, English is assumed.
/Leng English-language output [the default]
/Lfr French-language output
/P specifies a prefix string for the output
This optional parameter may always be specified or omitted.
Prefix string must be enclosed in single or double quotes
EXAMPLE: FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
SYMBOL CONVENTIONS
==================
The following symbols are used in specifying date formats:
SYMBOL EXAMPLE MEANING
------ ------- -------------------------------------
cc 19 century
yy 85 year
mm 02 month
zm 2 month without leading zero
dd 09 day
zd 9 day without leading zero
mn January month name
mn3 Jan month name, first 3 characters only
dow Tuesday day of week
dow3 Tue day of week, first 3 characters only
dow# 3 day of week as a number (Sunday=1, Monday = 2, etc.)
today is a "pseudodate" representing the current date
PSEUDODATES
===========
today can be used with either /A or /B, e.g. /Atoday.
EXAMPLE
rem Get the date that is 90 days from today
FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
rem determine if this year is a leapyear
FDATE /Fformat /Atoday /Oleapyr
INPUT FORMATS
=============
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
ccyymmdd 19862002
mm-dd-ccyy 02-20-1986 In an input format specification, the dash
02/20/1986 symbols represent ANY non-numeric symbol.
2/20/1986 Leading zeros need not be present.
mm-dd-yy 02-20-86 In this input format,
02/20/86 cc = 19 (century = 19) is assumed
NOTE
If "today" is the ONLY date specified, it is not
necessary to specify an input format using /I.
OUTPUT FORMATS
==============
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
ccyymmdd 19860220
yymmdd 860220
mmdd 0220
ccyymm 198602
In the following formats, months precede days (American style)
------------------------------------------------------------------
mm/dd/ccyy 02/20/1986
mm-dd-ccyy 02-20-1986
zm/zd/ccyy 2/20/1986 no leading zeros in day or month
zm-zd-ccyy 2-20-1986 no leading zeros in day or month
mm/dd/yy 02/20/86
mm-dd-yy 02-20-86
zm/zd/yy 2/20/86 no leading zeros in day or month
zm-zd-yy 2-20-86 no leading zeros in day or month
In the following formats, days precede months (European style)
------------------------------------------------------------------
mm/dd/ccyy 02/20/1986
mm-dd-ccyy 02-20-1986
zm/zd/ccyy 2/20/1986 no leading zeros in day or month
zm-zd-ccyy 2-20-1986 no leading zeros in day or month
mm/dd/yy 02/20/86
mm-dd-yy 02-20-86
zm/zd/yy 2/20/86 no leading zeros in day or month
zm-zd-yy 2-20-86 no leading zeros in day or month
------------------------------------------------------------------
dow# 5 Sunday=1, Monday=2 .... Saturday=7.
dow Thursday name of day of week
Jeudi if /Lfr specified
dow3 Thu first 3 characters of name of day of week
Jeu if /Lfr specified
------------------------------------------------------------------
leapyr 0 0 if year is a leapyear, otherwise 1.
------------------------------------
365 + this number gives total
number of days in the year.
28 + this number gives total
number of days in February.
------------------------------------
full 12:24pm on Saturday, February 5, 1992
12:24pm Samedi, le 5 Fevrier 1992 [/Lfr specified]
-----------------------------------------------------------------------
NOTE that the following formats contain embedded spaces. Consequently
they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
-----------------------------------------------------------------------
"zd mn ccyy" 5 February 1992
"zd mn, ccyy" 5 February, 1992
"mn3 dd ccyy" Feb 05 1992
"mn3 dd, ccyy" Feb 05, 1992
"mn zd, ccyy" February 5, 1992
"JULIAN" OUTPUT FORMATS
=======================
FORMAT EXAMPLES DISCUSSION
------ --------- -----------------------------
juldate 311 BUSINESS "Julian date" expressed as number
of days since January 1 of the same year.
day# 727198 TRUE "Julian date" expressed as number
of days since January 1, 0001.
minute# 33088 "Julian minutes": time expressed as number
of minutes since midnight, January 1, 1990.
second# 633088 "Julian seconds": time expressed as number
of seconds since midnight, January 1, 1990.
----------------------------------------------------------------------
Running FDATE with /O parameter for a "Julian time" produces a
number based on the current time of day and the date in the /A parm.
If, on January 10, 1992 at 2 pm, you run FDATE this way:
FDATE /Fformat /Atoday /Ominute#
it will produce the Julian minute for January 10, 1992 at 2 pm.
If, on January 10, 1992 at 2 pm, you run FDATE this way:
FDATE /Fformat /A01-15-1992 /Imm-dd-ccyy /Ominute#
it will produce the Julian minute for January 15, 1992 at 2 pm.
----------------------------------------------------------------------
DATE FUNCTIONS
==============
FUNCTION FDATE /Ffunc /Adate /Iformat /Oformat
-------- -------------------------------------------
/Fformat returns /Adate in format specified by /Oformat
Since /Aformat and /Oformat can be different, the FORMAT
function is used change a date from one format to another.
Because of the wide variety of output formats, the FORMAT
function can also be used to determine the day of week of the
date, whether the date is in a normal or leap year, etc.
EXAMPLES
FDATE /Fformat /A19920101 /Iccyymmdd /O"mn zd, ccyy"
FDATE /Fformat /Atoday /Odow
FUNCTION FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
-------- -------------------------------------------
/Fadd Adds /Ndays to /Adate, produces date in /Oformat format
/Fsub Subtracts /Ndays from /Adate, produces date in /Oformat format
EXAMPLES
FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
FUNCTION FDATE /Ffunc /Adate /Bdate /Iformat
-------- -------------------------------------------
/Fdif Returns number of days between /Adate and /Bdate
Order of the two dates is not significant.
Note that for DIF, both dates must be in the SAME
format, the input format specified in /Iformat.
If the two dates are not in the same format, reformat one
of the dates using the /Fformat function and
a utility like STRINGS or GET. See EXAMPLE #2, below.
EXAMPLES
FDATE /Fdif /A01-01-1992 /B11-11-1992 /Imm-dd-ccyy
FDATE /Fdif /A11-11-1992 /B01-01-1992 /Imm-dd-ccyy
FDATE /Fdif /Atoday /B01-01-1992 /Imm-dd-ccyy
MATH FUNCTIONS
==============
FUNCTION FDATE /Ffunc /Anum /Bnum
-------- -------------------------------------------
/F#dif returns the difference between the integers specified
on the /A and /B parms. Can be used to calculate the
number of minutes(seconds, days) between two
"Julian" minutes(seconds, dates).
/F#add returns the sum of the integers specified
on the /A and /B parms. Can be used to calculate the
"Julian" minute(second, date) in the future from a given
"Julian" minute(second, date).
/F#comp compares the integers specified on the /A and /B parms.
returns when
LT /A is less than /B
EQ /A is equal to /B
GT /A is greater than /B
See Example 3.
PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE
=================================================
FDATE's output is written to standard output, that is, it is displayed
on the screen. Output can be redirected to a file, or it can piped to
a utility (such as STRINGS or GET) that will put it into an
environment variable.
Manipulating the environment is an incredibly tricky business. There
are questions of the local versus master environment, the version of
DOS you are running, and the environment under which you are running
(DOS, Windows, Carousel). In order to keep FDATE focussed on
date-related issues, I have not attempted to make it put its output
directly into an environment variable.
One way to put FDATE's output into an environment variable is to use
the /P (prefix string) feature to create a DOS "SET" statement,
redirect the output to a batch file, and CALL the batch file.
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
There are also shareware and public domain utilities that are written
specifically to manipulate environment variables, and do that job very
well. FDATE's output can be put into an environment variable by
piping it to one of these utilities. When piping FDATE output to a
utility, redirecting the output to NUL will you can prevent the output
being ECHOed to the screen.
EXAMPLE: using STRINGS to put date into DATE1 environment variable
FDATE /Fformat /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
-----------------------------------------------------------------
I recommend Bob Stephan's GET and PC Magazine's STRINGS.
As of November 5, 1991, the current version of GET is GET24.ZIP.
On CompuServe, use IBMFF to look for GET*.ZIP in CIS:IBMSYS
GET is also available from the Public Software Library in Houston.
On CompuServe, look for STRING.ZIP in Utilities Lib of ZNT:UTILFORUM
-----------------------------------------------------------------
=======================================================================
EXAMPLE #1
Redirect FDATE output to a file, or to a callable batch file,
or pipe it to STRINGS or GET to store it in an environment variable
=======================================================================
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is " >FDATE.OUT
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
rem use STRINGS to put date into DATE1 environment variable
FDATE /Fformat /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
rem use GET (ver 2.3+) to put date into DATE1 environment variable
FDATE /Fformat /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
=======================================================================
EXAMPLE #2
Find the difference (in days) between two dates in different formats
Use GET to put FDATE output into environment variables.
=======================================================================
set date1=05-10-1992
rem reformat date literal into same format as date1
FDATE /Fformat /Imm-dd-yy /A05-08-92 /Omm-dd-ccyy | GET ZE /Vdate2>NUL
rem get difference between date1 and date2
FDATE /Fdif /Imm-dd-ccyy /A%date1% /B%date2%| GET ZE /vdiff>NUL
echo The difference is %diff% days.
=======================================================================
EXAMPLE #3
Schedule a program to run at a specified time in the future. Note that
this involves a lot of disk activity because DOS re-reads the batch
file from disk every time it does a GOTO LOOPTOP. If you do this, it
is probably a good idea to run the batch file from a RAM DISK.
=======================================================================
REM GET CURRENT JULIAN MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
FDATE /Fformat /Atoday /Ominute# |STRINGS RunTime= ASK >NUL
REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
FDATE /F#add /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
:LoopTop
FDATE /Fformat /Atoday /Ominute# |STRINGS NowTime= ASK >NUL
FDATE /F#comp /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
if (%TimeComp%)==(LT) goto loopTOP
:LoopEnd
echo STARTING EXECUTION OF APPLICATION: XXXXX
=======================================================================
EXAMPLE #4
Rename file BACKUP.LOG to a name that contains today's date
=======================================================================
FDATE /Fformat /Atoday /Oyymmdd /P"@SET DATE1=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
ren BACKUP.LOG BK%DATE1%.LOG
SET DATE1=
FDATE'S ALGORITHMS
==================
FDATE IS DESIGNED FOR BUSINESS, NOT HISTORICAL, APPLICATIONS
============================================================
FDATE is intended for business applications, not historical ones.
As far as FDATE is concerned, the calendar has followed the same
pattern, unchanged, since January 1, 0001.
-------------------------------------------------------------------
FDATE does not take into account historical changes in the calendar
such as the glitch in English dates that occurred when Britain
moved from the Julian to Gregorian calendar in the 18th century,
or Russia made the same move in the early 20th century.
-------------------------------------------------------------------
FDATE'S BASE DATE
=================
Internally, date manipulations are based on translating a calendar
date into an "absolute" or "TRUE Julian" date: a date expressed
as the number of days from some day in the distant past.
FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
FDATE's absolute date for January 1, 0001 is 1.
FDATE's absolute date for January 1, 1992 is 727198.
FDATE'S LEAP YEAR ALGORITHM
===========================
Every year evenly divisible by 4 IS a leap year
EXCEPT THAT
Every year evenly divisible by 100 IS NOT a leap year
EXCEPT THAT
Every year evenly divisible by 400 IS a leap year
.
Using this algorithm
1983 is not a leap year
1984 is a leap year
1900 is not a leap year
2000 is a leap year
See "A Machine Algorithm for Processing Calendar Dates", by
Henry F. Fliegel (Georgetown University Observatory)
Thomas C. Van Flandern (U.S. Naval Observatory)
COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
There is supposedly a new adjustment to the leapyear algorithm,
which specifies the additional exception:
EXCEPT THAT
Every year evenly divisible by 4000 IS a leap year
See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p. 148.
This adjustment is not part of FDATE's leapyear algorithm.
Unless your application is working with dates 2,000 years in the
future, the lack of this exception will be irrelevant for you.
USE AND DISTRIBUTION OF FDATE
=============================
FDATE is freeware. Although the author retains the copyright, FDATE
can be copied, used, and distributed freely as long as both FDATE and
its DOC file are not altered and are distributed together.
FDATE can be included in shareware packages as long as both FDATE and
its DOC file are included in the shareware package.
If you have received FDATE as part of some larger shareware package,
please be aware that you may freely use, copy, and distribute FDATE
without paying a fee for, or registering, the package.
The author explicitly disavows any claim whatsoever about the
functionality of the software, and disclaims liability for anything and
everything bad that might happen in connection with, before, during, or
after using it. I have tried to make FDATE work right, but everybody
makes mistakes, so you use FDATE at your own risk.
I don't know if people will find FDATE useful, and I'd like to find
out. If you find FDATE useful and use it on a regular basis, I'd
appreciate it if you would drop me a short note via US mail or
CompuServe, telling me about how you are using FDATE.
If you need other input/output formats, or if you need a different
leapyear algorithm, please contact the author.
FDATE REVISION HISTORY
======================
Letters appended to version numbers indicate modifications to
the DOC file, without any modification to the software.
1.1 Oct 01, 1991
First version
1.2 Oct 15, 1991
Replaced shareware date routines with Ferg routines
NOTE THAT THERE IS NOT MUCH ERROR-CHECKING IN THIS VERSION.
1.2d Oct 16, 1991
Minor changes to show redirection and piping of FDATE output
Revised discussion of how FDATE may be distributed.
Added note on business-related, non-historical purpose of FDATE
Added note on 4000-year leap-year exception
1.2e Oct 17, 1991
Added note on why FDATE doesn't directly set an Env variable
2.0a Nov 05, 1991
Modified Help display to show parameters and their meanings
Added output format YYMMDD
Added output format minute# and second#
Added function #dif
Added test of GET and STRINGS to test batch file.
Added test of minute# and second# to test batch file.
2.1a Nov 06, 1991
Added /P parameter and modified documentation accordingly
Added JULDATE output format
Minor changes and reformatting to documenation
2.2a Nov 08, 1991
Added example #4, showing how to put current date in a filename
Added MMDD output formats
2.3a Nov 09, 1991
Added /L (language parameter) to allow French-language output
Added the following output formats
full
"mn3 zd, ccyy"
"zd mn, ccyy"
"zd mn ccyy"
European-style date formats
in which day occurs before month (e.g. dd/mm/ccyy)
2.4a Nov 10, 1991
Fixed display of time in /Ofull so that a minutes value of
less than 10 would display with a leading zero:
e.g. "10:08 am" instead of "10:8 am".
2.5a Nov 13, 1991
Added output format CCYYMM
======================================================================
The following batch file can be used to test FDATE, and illustrates
the way it is used.
======================================================================
@ECHO OFF
BREAK ON
CLS
ECHO TEST HELP SCREEN
FDATE
@PAUSE
ECHO ON
CLS
@echo TEST PREFIX STRING FUNCTIONS
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
set FDATE=
FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT
ECHO Value of FDATE environment variable is: %FDATE%
set FDATE=
@PAUSE
CLS
@echo TEST TODAY AND ADD, SUB FUNCTIONS
FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
FDATE /Fsub /N90 /Atoday /Omm-dd-ccyy
FDATE /Fdif /Atoday /B01-01-1990 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fdif /A01-01-1990 /Btoday /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fdif /Atoday /Btoday /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST DIF
FDATE /Fdif /A12-31-0008 /B01-01-0009 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fdif /Iccyymmdd /A19801230 /B19801231
FDATE /Fdif /Iccyymmdd /A19801230 /B19801220
@PAUSE
CLS
@echo TEST DIF
FDATE /Fdif /Iccyymmdd /A19800101 /B19801231
FDATE /Fdif /Iccyymmdd /A19810101 /B19811231
FDATE /Fdif /Iccyymmdd /A20000101 /B20001231
FDATE /Fdif /Iccyymmdd /A19000101 /B19001231
FDATE /Fdif /Iccyymmdd /A16000101 /B16001231
@PAUSE
CLS
@echo TEST SUB
FDATE /Fsub /N1 /A12-31-0008 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /Atoday /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST ADD
FDATE /Fadd /N1 /A12-31-0008 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /Atoday /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST ADD ACROSS LEAP YEAR BOUNDARIES
FDATE /Fadd /N1 /A12-31-0003 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-0099 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-0399 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-1899 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-1999 /Imm-dd-ccyy /Omm-dd-ccyy
@PAUSE
CLS
FDATE /Fadd /N1 /A12-31-0004 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-0100 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-0400 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-1900 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fadd /N1 /A12-31-2000 /Imm-dd-ccyy /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST SUB BELOW LEAP YEAR BOUNDARIES
FDATE /Fsub /N1 /A12-31-0004 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A12-31-0100 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A12-31-0400 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A12-31-1900 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A12-31-2000 /Imm-dd-ccyy /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST SUB ACROSS LEAP YEAR BOUNDARIES
FDATE /Fsub /N1 /A01-01-0004 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-0100 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-0400 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-1900 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-2000 /Imm-dd-ccyy /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST SUB ACROSS LEAP YEAR BOUNDARIES
FDATE /Fsub /N1 /A01-01-0005 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-0101 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-0401 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-1901 /Imm-dd-ccyy /Omm-dd-ccyy
FDATE /Fsub /N1 /A01-01-2001 /Imm-dd-ccyy /Omm-dd-ccyy
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#1)
FDATE /Fformat /Atoday /Occyymmdd
FDATE /Fformat /Atoday /Oyymmdd
FDATE /Fformat /Atoday /Ommdd
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#2)
FDATE /Fformat /Atoday /Omm-dd-ccyy
FDATE /Fformat /Atoday /Ozm-zd-ccyy
FDATE /Fformat /Atoday /Omm/dd/ccyy
FDATE /Fformat /Atoday /Ozm/zd/ccyy
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#3)
FDATE /Fformat /Atoday /O"mn zd, ccyy"
FDATE /Fformat /Atoday /O"mn3 dd ccyy"
FDATE /Fformat /Atoday /O"mn3 dd, ccyy"
FDATE /fformat /atoday /Ofull /p"It is now "
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#4)
FDATE /Fformat /Atoday /Odow#
FDATE /Fformat /Atoday /Odow
FDATE /Fformat /Atoday /Odow3
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#3) (FRENCH)
FDATE /Fformat /Atoday /O"mn zd, ccyy" /Lfr
FDATE /Fformat /Atoday /O"mn3 dd ccyy" /Lfr
FDATE /Fformat /Atoday /O"mn3 dd, ccyy" /Lfr
FDATE /fformat /atoday /Ofull /p"Maintenant il est " /Lfr
@PAUSE
CLS
FDATE /Fformat /Atoday /Odow /Lfr
FDATE /Fformat /Atoday /Odow3 /Lfr
FDATE /Fformat /Atoday /O"zd mn ccyy" /Lfr
FDATE /Fformat /Atoday /O"zd mn, ccyy" /Lfr
@PAUSE
CLS
@echo TEST OUTPUT FORMATS (#5)
FDATE /Fformat /Atoday /Oday#
FDATE /Fformat /Atoday /Ominute#
FDATE /Fformat /Atoday /Osecond#
FDATE /Fformat /Atoday /Ojuldate
FDATE /Fformat /Atoday /Oleapyr
@PAUSE
CLS
@echo TEST ERROR MESSAGES
FDATE /Fformat /Atoday /OjuXdate
FDATE /Fformat /A18880101 /Iccyymmdd /Ominute#
FDATE /Fformat /A21010101 /Iccyymmdd /Ominute#
@REM missing A parm
FDATE /Fformat /today /Ofull
@PAUSE
CLS
@echo TEST LEAPYR (#1)
FDATE /Fformat /A01-01-0001 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-0004 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-0005 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-0100 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-0400 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-1600 /Imm-dd-ccyy /Oleapyr
@PAUSE
CLS
@echo TEST LEAPYR (#2)
FDATE /Fformat /A01-01-1900 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-1984 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-1991 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-1992 /Imm-dd-ccyy /Oleapyr
FDATE /Fformat /A01-01-2000 /Imm-dd-ccyy /Oleapyr
@PAUSE
CLS
@echo TEST ABILITY OF INPUT FORMAT TO HANDLE LEADING ZERO SUPPESSION
FDATE /Fformat /Imm-dd-YY /A06-06-66 /Ozm/zd/ccyy
FDATE /Fformat /Imm-dd-YY /A6-06-66 /Ozm/zd/ccyy
FDATE /Fformat /Imm-dd-YY /A06-6-66 /Ozm/zd/ccyy
FDATE /Fformat /Imm-dd-YY /A6-6-66 /Ozm/zd/ccyy
@PAUSE
CLS
@set date1=
@echo TEST FDATE WITH ENVIRONMENT MANIPULATION PROGRAMS
@echo reformat a date; use STRINGS to put it into DATE1 environment variable
FDATE /Fformat /A06-09-48 /Imm-dd-yy /O"mn zd, ccyy"|STRINGS date1= ASK >NUL
@echo DATE1 environment variable is %DATE1%
@echo.
@set date1=
@echo reformat a date; use GET to put it into DATE1 environment variable
FDATE /Fformat /A06-09-48 /Imm-dd-yy /O"mn zd, ccyy"|GET ZE /Vdate1 >NUL
@echo DATE1 environment variable is %DATE1%
@echo.
@set date1=
@echo reformat a date; use GET to put it into DATE1 environment variable
FDATE /Fformat /Atoday /Oyymmdd|GET ZE /Vdate1 >NUL
@echo DATE1 environment variable is %DATE1%
@echo.
@set date1=
@echo reformat a date; use GET to put it into DATE1 environment variable
FDATE /Fformat /Atoday /Occyymmdd|GET ZE /Vdate1 >NUL
@echo DATE1 environment variable is %DATE1%
@PAUSE
CLS
@ECHO LAST DAY OF YEAR 9999
FDATE /Fformat /A99991231 /iccyymmdd /Oday#
@ECHO.
@ECHO LAST DAY OF YEAR 2099
FDATE /Fformat /A20991231 /iccyymmdd /Oday#
@ECHO.
@ECHO FIRST DAY OF YEAR 0001
FDATE /Fformat /A00010101 /iccyymmdd /Oday#
@ECHO.
@ECHO FIRST DAY OF YEAR 1900
FDATE /Fformat /A19000101 /iccyymmdd /Oday#
@ECHO.
@ECHO FIRST DAY OF YEAR 1990
FDATE /Fformat /A19900101 /iccyymmdd /Oday#
@PAUSE
CLS
@echo TEST "JULIAN" OUTPUT FORMATS
FDATE /Fformat /Atoday /Ojuldate
FDATE /Fformat /Atoday /Oday#
FDATE /Fformat /Atoday /Ominute#
FDATE /Fformat /Atoday /Osecond#
FDATE /Fformat /A19950101 /Iccyymmdd /Ominute#
FDATE /Fformat /A19950101 /Iccyymmdd /Osecond#
@PAUSE
CLS
@ECHO OFF
@ECHO CALCULATE HOW LONG IT TOOK TO RUN A PROGRAM, IN SECONDS
REM GET PROGRAM BEGIN TIME, IN MINUTES
@set BegM=
@set EndM=
@set RunM=
FDATE /Fformat /Atoday /Ominute# /P"SET BegM=" >JUNKDATE.BAT
CALL junkdate.bat
REM GET PROGRAM BEGIN TIME, IN SECONDS
@set BegS=
@set EndS=
@set RunS=
FDATE /Fformat /Atoday /Osecond# /P"SET BegS=" >JUNKDATE.BAT
CALL junkdate.bat
rem ===============================================================
rem [simulate execution of a program: loop for a minute or less]
rem [In a real batch file, you would put your program statements here]
rem ===============================================================
:BegLoop
FDATE /Fformat /Atoday /Osecond# /P"SET EndS=" >JUNKDATE.BAT
CALL JUNKDATE.BAT
FDATE /Fformat /Atoday /Ominute# /P"SET EndM=" >JUNKDATE.BAT
CALL JUNKDATE.BAT
rem calculate run time (difference between start time and end time)
FDATE /F#dif /A%EndM% /B%BegM% /P"SET RunM=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
rem calculate run time (difference between start time and end time)
FDATE /F#dif /A%EndS% /B%BegS% /P"SET RunS=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
echo Elapsed time: %RunS% second(s)
if (%RunM%)==() goto EndLoop
if (%RunM%)==(0) goto BegLoop
:EndLoop
rem ===============================================================
REM GET PROGRAM END TIME IN MINUTES
FDATE /Fformat /Atoday /Ominute# /P"SET EndM=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
echo TEST---- program end time (Julian minutes): %EndM%
echo TEST---- program begin time (Julian minutes): %BegM%
rem calculate run time (difference between start time and end time)
FDATE /F#dif /A%EndM% /B%BegM% /P"SET RunM=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
DEL JUNKDATE.BAT
echo Program ran for %RunM% minute(s)
@set BegM=
@set EndM=
@set RunM=
echo.
REM GET PROGRAM END TIME IN SECONDS
FDATE /Fformat /Atoday /Osecond# /P"SET EndS=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
DEL JUNKDATE.BAT
echo TEST---- program end time (Julian seconds): %EndS%
echo TEST---- program begin time (Julian seconds): %BegS%
rem calculate run time (difference between start time and end time)
FDATE /F#dif /A%EndS% /B%BegS% /P"SET RunS=" > JUNKDATE.BAT
CALL JUNKDATE.BAT
DEL JUNKDATE.BAT
echo Program ran for %RunS% second(s)
@set BegS=
@set EndS=
@set RunS=
@PAUSE
@echo off
CLS
@echo END OF FDATE TEST BATCH FILE
:ENDIT